﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Drawing;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// 
    /// </summary>
    public struct GrayCornerFeatures
    {
        Point Position;
        float Orientation;
        float Angle;
        float GrayLevelIntensity;
    }

    /// <summary>
    /// Real Time Gray Level Corner Detector
    /// model of Fei Shen / Han Wang
    /// This is a structure based corner detector
    /// that uses homocentric circles
    /// </summary>
    public class GrayCornerDetector : BaseImageFilter, ICornerFinder
    {
        protected List<Point> m_aPoint = new List<Point>();
        protected List<GrayCornerFeatures> m_aGrayCornerFeatures = new List<GrayCornerFeatures>();
        protected int m_nThreshold = 25;

        /// <summary>
        /// Initializes a new instance of the <see cref="GrayCornerDetector"/> class.
        /// </summary>
        public GrayCornerDetector()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GrayCornerDetector"/> class.
        /// </summary>
        /// <param name="_grayCornerDetector">The _gray corner detector.</param>
        internal GrayCornerDetector(GrayCornerDetector _grayCornerDetector)
        {
            m_nThreshold = _grayCornerDetector.m_nThreshold;
        }

        /// <summary>
        /// Gets or sets threshold
        /// </summary>
        public int Threshold
        {
            get { return m_nThreshold; }
            set { m_nThreshold = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            int nWidth = _bitmap.Width;
            int nHeight = _bitmap.Height;

            for (int y = 0; y < nHeight; y++)
            {
                for (int x = 0; x < nWidth; x++)
                {

                }
            }
            return _bitmap;
        }

        /// <summary>
        /// 
        /// </summary>
        protected void CornerStructureConstraint()
        {
        }

        /// <summary>
        /// 
        /// </summary>
        protected void CornerResponse()
        {
        }

        /// <summary>
        /// Get points
        /// </summary>
        public List<Point> Points
        {
            get { return m_aPoint; }
        }

        /// <summary>
        /// This is used to clone a filter, each filter must implement it's own clone functionality
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new GrayCornerDetector(this);
        }
    }
}
